#ifndef STARS_H
#define STARS_H

#include <QDialog>
#include <QPainter>
#include <QTimer>

class Star {
public:
    Star(QWidget *parnt = nullptr) {
        x = qrand() % 640;
        y = qrand() % 480;
        step = (qrand() % 5000) / 1000.0 + 1;
        color = static_cast<int>((step / 6) * 255 + 0.5);
    }
    void move() {
        x = x + static_cast<int>(step);
        if (x > 640)
        {
            x = 0;
            y = qrand() % 480;
            step = (rand() % 5000) / 1000.0 + 1;
            color = static_cast<int>((step / 6) * 255 + 0.5);
        }
    }

    int x;
    int y;
    int color;
    double step;
};

class Stars : public QDialog
{
    Q_OBJECT

public:
    Stars(QWidget *parent = nullptr);
    ~Stars();

protected:
    void draw();
    void paintEvent(QPaintEvent *event);

private:
    Star *star[500];
    QTimer *timer;

};

#endif // STARS_H
